//
//  AjenView.h
//  AjenKit
//
//  Created by Ajen on 2017/7/13.
//  Copyright © 2017年 中国·北京·洵. All rights reserved.
//
//                       .::::.
//                     .::::::::.
//                    ::::Ajen:::
//                 ..:::::::::::'
//              '::::::::::::'
//                .::::::::::
//           '::::::::::::::..
//                ..::::::::::::.
//              ``::::::::::::::::
//               ::::``:::::::::'        .:::.
//              ::::'   ':::::'       .::::::::.
//            .::::'      ::::     .:::::::'::::.
//           .:::'       :::::  .:::::::::' ':::::.
//          .::'        :::::.:::::::::'      ':::::.
//         .::'         ::::::::::::::'         ``::::.
//     ...:::           ::::::::::::'              ``::.
//    ````              ':::::::::'                  ::::..
//                       '.:::::'                    ':'````..
//  [······view拓展······]
//

//  使用方法 self.view.aj_bgColorHexSre(@"#333333").aj_cornerRadius(20);
//  说明 :
//      (1) 如果定义一个Label,先赋值Label独有属性,再赋值Label父类属性 (先赋值文字颜色,再赋值背景颜色)
//      (2) 父类 - UIView
#import <UIKit/UIKit.h>


IB_DESIGNABLE
@interface AjenView : UIView

@end

#pragma mark -
#pragma mark - UIView拓展

IB_DESIGNABLE
@interface UIView (AjenView)
///* * * * * tag * * * * *
-(UIView *(^)(NSInteger  aj_tag))aj_tag;

///* * * * * 添加到 * * * * *
-(UIView *(^)(UIView * aj_addToView))aj_addToView;

///* * * * * 透明度 * * * * *
-(UIView *(^)(CGFloat  aj_alpha)) aj_alpha;

///* * * * * 设置背景色 * * * * *
- (UIView *(^)(UIColor * aj_bgColor))aj_bgColor;

///* * * * * 设置背景色(16进制) * * * * *
- (UIView *(^)(NSString * aj_bgColorHexStr))aj_bgColorHexStr;

///* * * * * 设置边框宽度 * * * * *
- (UIView *(^)(CGFloat  aj_borderWidth))aj_borderWidth;

///* * * * * 设置边框颜色 * * * * *
- (UIView *(^)(UIColor * aj_borderColor))aj_borderColor;

///* * * * * 设置边框颜色(16进制) * * * * *
- (UILabel *(^)(NSString * aj_borderColorHexStr)) aj_borderColorHexStr;

///* * * * * 设置圆角角度 * * * * *
- (UIView *(^)(CGFloat  aj_cornerRadius))aj_cornerRadius;

///* * * * * 设置x起点 * * * * *
- (UIView *(^)(CGFloat  aj_frame_x))aj_frame_x;

///* * * * * 设置y起点 * * * * *
- (UIView *(^)(CGFloat  aj_frame_y))aj_frame_y;

///* * * * * 设置宽度 * * * * *
- (UIView *(^)(CGFloat  aj_frame_w))aj_frame_w;

///* * * * * 设置高度 * * * * *
- (UIView *(^)(CGFloat  aj_frame_h))aj_frame_h;

///* * * * * 设置中心x位置 * * * * *
- (UIView *(^)(CGFloat  aj_frame_center_x))aj_frame_center_x;

///* * * * * 设置中心y位置 * * * * *
- (UIView *(^)(CGFloat  aj_frame_center_y))aj_frame_center_y;

///* * * * * 设置frame * * * * *
- (UIView *(^)(CGRect   aj_frameRect))aj_frameRect;

///递归显示View及子View的边框.测试显示,会递归将视图本身的周围显示一个带颜色的边框,还会将视图下的所有子视图的所有子视图的所有子视图...显示带颜色的边框
-(void)displayTest;

///获取Xib View对象
+(id)loadXibString:(NSString *)xibName;

/**  起点x坐标  */
@property (nonatomic, assign) CGFloat X;
/**  起点y坐标  */
@property (nonatomic, assign) CGFloat Y;
/**  中心点x坐标  */
@property (nonatomic, assign) CGFloat CenterX;
/**  中心点y坐标  */
@property (nonatomic, assign) CGFloat CenterY;
/**  宽度  */
@property (nonatomic, assign) CGFloat Width;
/**  高度  */
@property (nonatomic, assign) CGFloat Height;
/**  顶部  */
@property (nonatomic, assign) CGFloat Top;
/**  底部  */
@property (nonatomic, assign) CGFloat Bottom;
/**  左边  */
@property (nonatomic, assign) CGFloat Left;
/**  右边  */
@property (nonatomic, assign) CGFloat Right;
/**  size  */
@property (nonatomic, assign) CGSize Size;
/**  origin */
@property (nonatomic, assign) CGPoint Origin;

- (BOOL)isDisplayedInScreen;

- (void)addTapBlock:(void(^)(id obj))tapAction;

@property (nonatomic,assign) IBInspectable BOOL AJ_裁剪;//给Xib视图用的,能在Xib的操作面板里面直接设置裁剪
@property (nonatomic,assign) IBInspectable CGFloat AJ_圆角;//给Xib视图用的,能在Xib的操作面板里面直接设置圆角
@property (nonatomic,assign) IBInspectable CGFloat AJ_边框粗细;//给Xib视图用的,能在Xib的操作面板里面直接设置边框粗细
@property (nonatomic,assign) IBInspectable UIColor * AJ_边框颜色;//给Xib视图用的,能在Xib的操作面板里面直接设置边框颜色

///删除所有子视图
-(void)removeAllSubviews;

@end

#pragma mark -
#pragma mark - UILabel拓展

@interface UILabel (AjenLabel)

///* * * * * 设置字体 * * * * *
- (UILabel *(^)(UIFont * aj_font)) aj_font;

///* * * * * 设置字号(默认字体) * * * * *
- (UILabel *(^)(CGFloat  aj_fontFloat)) aj_fontFloat;

///* * * * * 设置文字颜色 * * * * *
- (UILabel *(^)(UIColor * aj_textColor)) aj_textColor;

///* * * * * 设置文字颜色(16进制) * * * * *
- (UILabel *(^)(NSString * aj_textColorHexStr)) aj_textColorHexStr;

///* * * * * 设置居左居中居右 * * * * *
- (UILabel *(^)(NSTextAlignment  aj_textAlignment)) aj_textAlignment;

///* * * * * 设置换行数 * * * * *
- (UILabel *(^)(CGFloat  aj_numberOfLines)) aj_numberOfLines;

///* * * * * 设置换行数 * * * * *
- (UILabel *(^)(NSString * aj_Text)) aj_Text;

///* * * * * 宽度自动延展 * * * * *
- (UILabel *(^)(CGFloat MaxWidth)) aj_AutoWidth;
//label2.preferredMaxLayoutWidth = 150;
//[label2 setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];


///* * * * * 设置带删除线的文字 * * * * *
- (UILabel *(^)(NSString * aj_DeleteStyleText)) aj_DeleteStyleText;

@end


#pragma mark -
#pragma mark - UITextField拓展


@interface UITextField  (AjenTextField)

///* * * * * 设置字体 * * * * *
- (UITextField *(^)(UIFont * aj_font)) aj_font;

///* * * * * 设置字号(默认字体) * * * * *
- (UITextField *(^)(CGFloat  aj_fontFloat)) aj_fontFloat;

///* * * * * 设置文字颜色 * * * * *
- (UITextField *(^)(UIColor * aj_textColor)) aj_textColor;

///* * * * * 设置文字颜色(16进制) * * * * *
- (UITextField *(^)(NSString * aj_textColorHexStr)) aj_textColorHexStr;

///* * * * * 设置居左居中居右 * * * * *
- (UITextField *(^)(NSTextAlignment  aj_textAlignment)) aj_textAlignment;

///* * * * * 设置"完成"按钮文字 * * * * *
- (UITextField *(^)(NSString * aj_toolbarOKItemName)) aj_toolbarOKItemName;

- (NSRange)selectedRange;

- (void)setSelectedRange:(NSRange)range;

@end

#pragma mark -
#pragma mark - UITextView拓展


@interface UITextView  (AjenTextView)

///* * * * * 设置字体 * * * * *
- (UITextView *(^)(UIFont * aj_font)) aj_font;

///* * * * * 设置字号(默认字体) * * * * *
- (UITextView *(^)(CGFloat  aj_fontFloat)) aj_fontFloat;

///* * * * * 设置文字颜色 * * * * *
- (UITextView *(^)(UIColor * aj_textColor)) aj_textColor;

///* * * * * 设置文字颜色(16进制) * * * * *
- (UITextView *(^)(NSString * aj_textColorHexStr)) aj_textColorHexStr;

///* * * * * 设置居左居中居右 * * * * *
- (UITextView *(^)(NSTextAlignment  aj_textAlignment)) aj_textAlignment;

///* * * * * 设置"完成"按钮文字 * * * * *
- (UITextView *(^)(NSString * aj_toolbarOKItemName)) aj_toolbarOKItemName;

@end


@interface UIImageView  (AjenImageView)

///* * * * * 设置图片(图片名) * * * * *
-(UIImageView * (^)(NSString * aj_imgName)) aj_imgName;

///* * * * * 设置是否填充 * * * * *
-(UIImageView * (^)(BOOL aj_imgIsFill))  aj_imgIsFill;

@end


@interface UIButton (AjenButton)

///* * * * * 设置点击方法 * * * * *
-(UIButton * (^)(SEL aj_selector)) aj_selector;

///* * * * * 设置点击方法 * * * * *
-(UIButton * (^)(id target ,SEL aj_selector)) aj_addTargetSelector;

///* * * * * 设置titleText * * * * *
-(UIButton * (^)(NSString * aj_buttonTitle)) aj_buttonTitle;

///* * * * * 设置title字体 * * * * *
-(UIButton * (^)(UIFont * aj_buttonFont)) aj_buttonFont;

///* * * * * 设置title字号(默认字体) * * * * *
-(UIButton * (^)(CGFloat  aj_buttonFontFloat)) aj_buttonFontFloat;

///* * * * * 设置title颜色 * * * * *
-(UIButton * (^)(UIColor * aj_buttonTintColor)) aj_buttonTintColor;

///* * * * * 设置title颜色(16进制) * * * * *
-(UIButton * (^)(NSString * aj_buttonTintColorHex)) aj_buttonTintColorHex;

///* * * * * 设置img * * * * *
-(UIButton * (^)(UIImage * aj_buttonImg)) aj_buttonImg;

///* * * * * 设置img(图片名) * * * * *
-(UIButton * (^)(NSString * aj_buttonImgName)) aj_buttonImgName;

///* * * * * 设置换行数 * * * * *
- (UIButton *(^)(CGFloat  aj_numberOfLines)) aj_numberOfLines;

///* * * * * 扩大点击范围 * * * * *
-(void)setEnlarge:(CGFloat)enlarge;

///* * * * * 扩大点击范围 * * * * *
-(void)setEnlargeEdgeWithTop:(CGFloat)top right:(CGFloat)right bottom:(CGFloat)bottom left:(CGFloat)left;

@end

@interface UIColor (AjenStrColor)

+ (UIColor *)colorWithAjenHexString:(NSString *)hexString;
+ (UIColor *)colorWithAjenHex:(NSInteger)hexValue alpha:(CGFloat)alphaValue;

@end

typedef NS_OPTIONS(NSUInteger, UIBorderSideType) {
    UIBorderSideTypeAll  = 0,
    UIBorderSideTypeTop = 1 << 0,
    UIBorderSideTypeBottom = 1 << 1,
    UIBorderSideTypeLeft = 1 << 2,
    UIBorderSideTypeRight = 1 << 3,
};

@interface UIView (BorderLine)

- (UIView *)borderForColor:(UIColor *)color borderWidth:(CGFloat)borderWidth borderType:(UIBorderSideType)borderType;

@end  

@interface UITableViewCell (XIB)
+(UITableViewCell *)loadXibCellWithTableView:(UITableView *)tableView iden:(NSString *)iden;
@end
